<template>
  <PageBox :data="dataInfo" @searchBtn="getTbody" :maring="maring" :isRadio="isRadio" :isCheckbox="isCheckbox"
    @tableCheckboxBtn="tableCheckboxBtn" @tableRadioBtn="tableRadioBtn">
    <template #search="{ search }">
      <ElFormItemBox label="时间范围">
        <ElDaysBox :data="search" :dataName="['beginTime', 'endTime']" />
      </ElFormItemBox>
    </template>
    <template #headR></template>
    <template #scrapBillStateName="{ row }">
      <ElTagBox :data="row.scrapBillState" :options="options.state" />
    </template>
    <template #scrapBillNo="{ row }">
      <PopoverTabel :title="row.scrapBillNo" :width="1200" :thead="[
        {
          label: '物料名称',
          prop: 'goodsName',
          align: 'left',
          width: 220
        },
        {
          label: '规格型号',
          prop: 'specificationName',
          align: 'left',
          width: 80
        },
        {
          label: '供应商',
          prop: 'supplierName',
          align: 'left',
          width: 160
        },
        {
          label: '物料类型',
          prop: 'categoryName',
          align: 'center',
          width: 80
        },
        {
          label: '使用单位',
          prop: 'goodsUnitName',
          align: 'center',
          width: 80
        },
        {
          label: '批次编号',
          prop: 'productionBatchNumber',
          align: 'center',
          width: 80
        },
        {
          label: '生产日期',
          prop: 'productionDate',
          align: 'center',
          width: 100
        },
        {
          label: '库区库位',
          prop: 'wareHouseAreaSheltName',
          align: 'center',
          width: 140
        },
        {
          label: '报废数量',
          prop: 'scrapQuantity',
          align: 'center',
          width: 80,
        },
        {
          label: '备注',
          prop: 'scrapDetailRemark',
          align: 'left',
          width: null,
        }
      ]" @show="(table: any) => {
        proxy.$api.GoodsScrapBill.GetGoodsScrapBillDetail({
          code: row.scrapBillCode,
        })
          .then((res: any) => {
            table.tbody = res.mxDataList
            table.loading = false
          })
          .catch(() => { });
      }">
        <template #productionDate="{ row }">
          {{ proxy.$day(row.productionDate) }}
        </template>
      </PopoverTabel>
    </template>
  </PageBox>
</template>
<script setup lang="ts">
import { useRouter } from 'vue-router';
const router = useRouter();
const { proxy } = getCurrentInstance() as any;
import './pageCss.scss'; // 引入样式
import { useListComponent } from './pageTs'; // 引入逻辑
const props = withDefaults(
  defineProps<{
    isRadio?: boolean; //单选
    isCheckbox?: boolean; //多选
    maring?: number; //多选
  }>(),
  {
  },
);

const emit = defineEmits<{
  //fn为父组件引入子组件是定义的子组件事件属性，可随意定义
  (event: 'tableRadioBtn', row: any): void;
  (event: 'tableCheckboxBtn', arr: any): void;
}>();
//多选数据
const tableCheckboxBtn = (arr: any) => {
  emit('tableCheckboxBtn', arr);
};
//单选数据
const tableRadioBtn = (row: any) => {
  emit('tableRadioBtn', row);
};
// 组件挂载后执行
onMounted(() => {
  getTbody();
});
const { dataInfo, getTbody, options } = useListComponent({
  ...props,
});
</script>